﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VoiceAI;
using VoiceAI.VoiceResponse;

namespace Xiaowei.ResponseHandlers
{
    public static class WeatherResponseHandler
    {
        public static void Handle(IResponseData responseData)
        {
            if (responseData is IWeatherResponseData weatherResponse)
            {
                Models.WeatherModel weatherModel = new Models.WeatherModel();
                weatherModel.currentInfo = weatherResponse.CurrentInfo;
                weatherModel.Location = weatherResponse.Location;
                foreach (var item in weatherResponse.WeatherInfoList)
                {
                    weatherModel.InfoList.Add(
                        new Models.WeatherData()
                        {
                            Condition = WeatherConditionMap[item.Condition],
                            Date = item.Date,
                            Temperature = item.Temperature,
                            MaxTemperature = item.MaxTemperature + "℃",
                            MinTemperature = item.MinTemperature + "℃",
                            PM25 = item.PM25,
                            Quality = item.Quality,
                            WindDirection = item.WindDirection,
                            WindLevel = item.WindLevel
                        }
                    );
                }
                weatherResponse.DataContext = weatherModel;
            }
            DefaultResponseHandler.Handle(responseData);
        }



        private static Dictionary<WeatherCondition, string> WeatherConditionMap = new Dictionary<WeatherCondition, string>()
        {
            {WeatherCondition.Sunny,"晴"},
            {WeatherCondition.MostlySunny,"大部晴朗"},
            {WeatherCondition.Cloudy,"多云"},
            {WeatherCondition.PartlyCloudy,"少云"},
            {WeatherCondition.Overcast,"阴"},
            {WeatherCondition.Shower,"阵雨"},
            {WeatherCondition.PartialShower,"局部阵雨"},
            {WeatherCondition.SmallShower,"小阵雨"},
            {WeatherCondition.StrongShower,"强阵雨"},
            {WeatherCondition.SnowShower,"阵雪"},
            {WeatherCondition.SmallSnowShower,"小阵雪"},
            {WeatherCondition.Fog,"雾"},
            {WeatherCondition.FrozenFog,"冻雾"},
            {WeatherCondition.Sandstorm,"沙尘暴"},
            {WeatherCondition.FloatingDust,"浮尘"},
            {WeatherCondition.DustyWind,"尘卷风"},
            {WeatherCondition.BlowingSand,"扬沙"},
            {WeatherCondition.StrongSandstorm,"强沙尘暴"},
            {WeatherCondition.Haze,"霾"},
            {WeatherCondition.Thundershower,"雷阵雨"},
            {WeatherCondition.Raiden,"雷电"},
            {WeatherCondition.Thunderstorm,"雷暴"},
            {WeatherCondition.ThunderShower2,"雷阵雨伴"},
            {WeatherCondition.Hail,"冰雹"},
            {WeatherCondition.IceNeedle,"冰针"},
            {WeatherCondition.IceParticle,"冰粒"},
            {WeatherCondition.Sleet,"雨夹雪"},
            {WeatherCondition.LightRain,"小雨"},
            {WeatherCondition.ModerateRain,"中雨"},
            {WeatherCondition.HeavyRain,"大雨"},
            {WeatherCondition.Rainstorm,"暴雨"},
            {WeatherCondition.HeavyRainstorm,"大暴雨"},
            {WeatherCondition.ExtraHeavyRainstorm,"特大暴雨"},
            {WeatherCondition.LightSnow,"小雪"},
            {WeatherCondition.ModerateSnow,"中雪"},
            {WeatherCondition.HeavySnow,"大雪"},
            {WeatherCondition.Blizzard,"暴雪"},
            {WeatherCondition.FreezingRain,"冻雨"},
            {WeatherCondition.Snow,"雪"},
            {WeatherCondition.Rain,"雨"},
            {WeatherCondition.LightToModerateRain,"小到中雨"},
            {WeatherCondition.ModerateToHeavyRain,"中到大雨"},
            {WeatherCondition.HeavyRainToRainStorm,"大到暴雨"},
            {WeatherCondition.SmallToMediumSnow,"小到中雪"},
            {WeatherCondition.SunnyNight,"晴_晚上"},
            {WeatherCondition.MostlySunnyNight,"大部晴朗_晚上"},
            {WeatherCondition.CloudyNight,"多云_晚上"},
            {WeatherCondition.PartlyCloudyNight,"少云_晚上"},
            {WeatherCondition.OvercastNight,"阴_晚上"},
            {WeatherCondition.ShowerNight,"阵雨_晚上"},
            {WeatherCondition.PartialShowerNight,"局部阵雨_晚上"},
            {WeatherCondition.SmallShowerNight,"小阵雨_晚上"},
            {WeatherCondition.StrongShowerNight,"强阵雨_晚上"},
            {WeatherCondition.SnowShowerNight,"阵雪_晚上"},
            {WeatherCondition.SmallSnowShowerNight,"小阵雪_晚上"},
            {WeatherCondition.FogNight,"雾_晚上"},
            {WeatherCondition.FrozenFogNight,"冻雾_晚上"},
            {WeatherCondition.SandstormNight,"沙尘暴_晚上"},
            {WeatherCondition.FloatingDustNight,"浮尘_晚上"},
            {WeatherCondition.DustyWindNight,"尘卷风_晚上"},
            {WeatherCondition.BlowingSandNight,"扬沙_晚上"},
            {WeatherCondition.StrongSandstormNight,"强沙尘暴_晚上"},
            {WeatherCondition.HazeNight,"霾_晚上"},
            {WeatherCondition.ThundershowerNight,"雷阵雨_晚上"},
            {WeatherCondition.RaidenNight,"雷电_晚上"},
            {WeatherCondition.ThunderstormNight,"雷暴_晚上"},
            {WeatherCondition.ThunderShower2Night,"雷阵雨伴_晚上"},
            {WeatherCondition.HailNight,"冰雹_晚上"},
            {WeatherCondition.IceNeedleNight,"冰针_晚上"},
            {WeatherCondition.IceGrainNight,"冰粒_晚上"},
            {WeatherCondition.SleetNight,"雨夹雪_晚上"},
            {WeatherCondition.LightRainNight,"小雨_晚上"},
            {WeatherCondition.ModerateRainNight,"中雨_晚上"},
            {WeatherCondition.HeavyRainNight,"大雨_晚上"},
            {WeatherCondition.RainstormNight,"暴雨_晚上"},
            {WeatherCondition.HeavyRainstormNight,"大暴雨_晚上 "},
            {WeatherCondition.ExtremelyHeavyRainNight,"特大暴雨_晚上"},
            {WeatherCondition.LightSnowNight,"小雪_晚上"},
            {WeatherCondition.ModerateSnowNight,"中雪_晚上"},
            {WeatherCondition.HeavySnowNight,"大雪_晚上"},
            {WeatherCondition.BlizzardNight,"暴雪_晚上"},
            {WeatherCondition.FreezingRainnight,"冻雨_晚上"},
            {WeatherCondition.SnowNight,"雪_晚上"},
            {WeatherCondition.RainNight,"雨_晚上"},
            {WeatherCondition.SmallToModerateRainNight,"小到中雨_晚上"},
            {WeatherCondition.ModerateToHeavyRainNight,"中到大雨_晚上"},
            {WeatherCondition.HeavyRainToRainStormNight,"大到暴雨_晚上"},
            {WeatherCondition.SmallToMediumSnowNight,"小到中雪_晚上"},
            {WeatherCondition.Error,"错误"},

        };
    }

}
